<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>BF++</title>
    <script src="js/util.js"></script>
</head>
<body>
<style>

    .line {
        display:block;
        margin:10px auto;
        font-size:2rem;
        text-align:left;
    }

    div.center {
        text-align:center;
    }

    .width {
        width:90%;
        margin:auto;
    }
    .font_2rem {
        font-size:2rem;
     }

    .result {
        color: white;
        background: black;
        padding: 10px;
    }

</style>

<div style="text-align:center;">
    <!--    <div class="line center">X</div>-->
    <!--    <textarea class="line width" id="x" readonly rows="2">hello,world!-->
    <!--Hello World!</textarea>-->
    <!--    <button class="line" onclick="compileX()">compile to java</button>-->
    <!--    <textarea class="line width" id="java" readonly rows="1">System.out.println("hello,world!");</textarea>-->
    <!--    <button class="line" onclick="compileJava()">BF++</button>-->
    <div class="line center">BF++</div>
    <textarea class="line width" id="code" style="height:300px;">
#原始版本HelloWorld
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[<++++>-]<+.[-]++++++++++.
&_>_>_>_&

#BF++ HelloWorld-v1
>+9[<+8>-]<.>+7[<+4>-]<+.+7.2+3._>+8[<+4>-]<.>+11[<+5>-]<.>+8[<+3>-]<.+3.-6.-8._>+8[<+4>-]<+._+10.&_

#BF++ HelloWorld-v2
+72.>+101.>+108.>+108.>+111.>+32.>+87.>+111.>+114.>+108.>+100.>+33.>+13.>+10.>&_

#BF++ HelloWorld-v3
+72.+29.+7..+3.-79.+55.+24.+3.-6.-8.-67._+10.

#BF++ HelloWorld-v4
(,.)12

</textarea>
    <div class="line center">input</div>
    <input class="line width" id="input" value="Hello World!">
    <button class="line" onclick="run()">run</button>
    <div class="line center">result</div>
    <pre class="line width result" id="result"></pre>
</div>
<div>

<pre class="font_2rem width ">
BF++: Brain F**k的扩展
 1，指令扩展：&(重置到首位)，_(单元格置0)，^(无条件break)，!(有条件break,条件和[一样)
 2，语法扩展：指令后面带数字，表示重复多少次，减少输入；支持括号后面重复N次；比如：输出A， +65.
 3，注释：#开头

更多资源：
<a href="https://github.com/yanchangyou/turing-machine-world" target="_blank">github</a>
<a href="http://www.muppetlabs.com/~breadbox/bf/" target="_blank">BF</a>
<a href="https://baike.baidu.com/item/Brainfuck" target="_blank">百度百科</a></pre>
</div>
<script>

    function run() {
        var code = document.getElementById("code").value;
        var input = document.getElementById("input").value;
        var formData = 'code='+encodeURIComponent(code);
        formData += "&input="+encodeURIComponent(input);
        var url = "/api/index/execute";

        postForm(url, formData, function(result) {

            document.getElementById("result").innerHTML = result;
        });
    }
</script>
</body>
</html>